{% extends "base.html" %}

{% block title %}菜单管理 - 网站管理后台{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">菜单管理</h1>
    <div class="btn-toolbar mb-2 mb-md-0">
        <div class="btn-group me-2">
            <a href="{{ url_for('web.add_menu') }}" class="btn btn-sm btn-outline-secondary">
                <i class="fas fa-plus"></i> 添加菜单
            </a>
        </div>
    </div>
</div>

<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>父级ID</th>
                <th>菜单名称</th>
                <th>图标</th>
                <th>路径</th>
                <th>排序</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for menu in menus %}
            <tr>
                <td>{{ menu[0] }}</td>
                <td>{{ menu[1] }}</td>
                <td>{{ menu[2] }}</td>
                <td>
                    {% if menu[3] %}
                        <i class="{{ menu[3] }}"></i> {{ menu[3] }}
                    {% else %}
                        -
                    {% endif %}
                </td>
                <td>{{ menu[4] if menu[4] else '-' }}</td>
                <td>{{ menu[6] }}</td>
                <td>
                    {% if menu[7] == 1 %}
                        <span class="badge bg-success">显示</span>
                    {% else %}
                        <span class="badge bg-secondary">隐藏</span>
                    {% endif %}
                </td>
                <td>{{ menu[10] }}</td>
                <td>
                    <a href="{{ url_for('web.edit_menu', menu_id=menu[0]) }}" class="btn btn-sm btn-outline-primary">
                        <i class="fas fa-edit"></i> 编辑
                    </a>
                    <form action="{{ url_for('web.delete_menu', menu_id=menu[0]) }}" method="POST" style="display: inline;">
                        <button type="submit" class="btn btn-sm btn-outline-danger" 
                                onclick="return confirm('确定要删除这个菜单吗？')">
                            <i class="fas fa-trash"></i> 删除
                        </button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}